$(function(){
	$("input[type='button']").click(function(){
		if (confirm("确认要进行" + $(this).val() + "操作？")) {
            reflesh($(this).attr("code"));
            
            oldVal = $(this).attr('disabled',"true").val();
            setTimeout("timedCount()",1000);
        }
	});
});

function reflesh(code) {
	$.post(contextPath + '/refleshCache', {code:code},
		function(data) {
			if (data && data.code) {
				if(data.code == 1) {
					alert("操作成功！");
				} else {
					alert("操作失败！");
				}
			} else {
				alert("操作失败！");
			}
		}, "json");
}

var t;
var oldVal;
var c = 60;
function timedCount() { 
	c -= 1;
	if(c == 0) {
		$(this).attr('disabled',"false").val(oldVal);
		stopCount();
	}
} 
function stopCount() { 
	clearTimeout(t) 
}